///////////////////////////////////////////////////////////////////////////
// Copyright 2009 Arabic Game Developer Network All rights reserved
// www.agd-online.com - info@agdn-online.com
// Parts of this code are based on code originally authored by Ahmed Ezz and
// Salwan Alhilali for the kvalley2 project.
// Copyright 2008, In|Framez Co., All rights reserved
// 
// File: game.h
// Description: Valley's main include file. Contains major #defines
//				and global functionalities...
//
///////////////////////////////////////////////////////////////////////////

// This file is part of kvalleyX.
// 
// kvalleyX is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// kvalleyX is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with kvalleyX.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _GAME_H
#define _GAME_H

/////////////////// #defines //////////////////////////////////////////////
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define GAME_FPS 60

#define CHAMBER_LEFT 16
#define CHAMBER_TOP 64
#define CHAMBER_RIGHT (SCREEN_WIDTH-16)                      // 624
#define CHAMBER_BOTTOM (SCREEN_HEIGHT-80)                    // 400
#define CHAMBER_WIDTH (CHAMBER_RIGHT-CHAMBER_LEFT)           // 608
#define CHAMBER_HEIGHT (CHAMBER_BOTTOM-CHAMBER_TOP)          // 336
#define CHAMBER_CELL 16
#define CHAMBER_CELLS_X (CHAMBER_WIDTH/CHAMBER_CELL)         // 38
#define CHAMBER_CELLS_Y (CHAMBER_HEIGHT/CHAMBER_CELL)        // 21
///TODO: verify whether we still need the following defines or not.
//#define _CRT_SECURE_NO_DEPRECATE // Visual Studio 2005 security checks
//#define _CRT_NONSTDC_NO_DEPRECATE


/////////////////// #includes /////////////////////////////////////////////

using namespace std;

//#include "DataStructures.h"
#include "core2.h"
#include "input.h"
#include "stdio.h"
#include "audio.h"
#include "text.h"
// #include "Sprites.h"
// #include "Backgrounds.h"
// #include "DoorsGates.h"
// #include "Creatures.h"
// #include "Collectables.h"
// #include "Monsters.h"
// #include "Explorer.h"
// #include "Chambers.h"
// #include "Pyramids.h"
// #include "stateflow.h"
#include "gamestates.h"


/////////////////// Game Functions ////////////////////////////////////////
enum GameDirectories
{
	GameDir_Config,
	GameDir_SpriteArt,
	GameDir_BackgroundArt,
	GameDir_BlockArt,
	GameDir_Font,
	GameDir_Level,
	GameDir_Audio,
};
bool GetGameFilePath(char *pszOutPath,const char *pszFileName,GameDirectories dirBase);

enum GameControls
{
	GameControl_Enter,		// Return key at main menu
	GameControl_Select,		// Spacebar at the main menu
	GameControl_Up,			// Up
	GameControl_Down,		// Down
	GameControl_Left,		// Left
	GameControl_Right,		// Right
	GameControl_Jump,		// Spacebar at the game
	GameControl_Use,		// CTRL at the game
	GameControl_MainMenu,	// F3 at the game
	GameControl_RestartLevel,//F2 at the game
	GameControl_BackSpace,	// Back-space at password screen
	GameControl_Escape,		// Escape at password or pause screen
	GameControl_Pause,		// Enter/escape pause screen
	GameControl_Quit,		// Close and quit the program
};
// --End

/////////////////// Config Struct Declaration /////////////////////////////
struct CONFIG// : public GameData::Config
{
	/*SpriteArt *pExplorerWalkArt;
	SpriteArt *pExplorerAxeArt;
	SpriteArt *pExplorerSwordArt;
	SpriteArt *pExplorerDigArt;
	SpriteArt *pExplorerShootArt;
	SpriteArt *pExplorerTorchArt;
	SpriteArt *pExplorerTorchStandArt;
	*/
};


/////////////////// Stats Struct Declaration //////////////////////////////
struct STATS
{
	void AddScore(int iPoints)
	{
		iScore += iPoints;
		if (iScore > iHighScore) iHighScore = iScore;
	}
	int iCurrentLevel;
	int iLevelCleared;
	int iScore;
	int iHighScore;
	int iAttempts;
};


/////////////////// Game Class Declaration /////////////////////////////
class Game : public CoreLib::BaseApp
{
	private:
		void SetupGameControls(void);
		void SwitchFullscreen(void);
		bool LoadConfig(void);
		GameStateFlow stateFlow;
		char m_szStatsText[64];
		bool m_bFullScreen;
		bool m_bDrawGrid;
		Game();

	public:
		static Game& getInstance();
		virtual ~Game();
		virtual bool update(void);
		//virtual bool draw(uint32_t ellapsedTime);
		bool init(void);
		//void UpdateStatsText(void);
		//void DrawStats(bool bCopyrights);
	

	//StateFlow& GetStateFlow(void) { return m_StateFlow; }
	
		bool GetDrawGrid(void) { return m_bDrawGrid; }
		void SetDrawGrid(bool bEnable) { m_bDrawGrid = bEnable; }

		FontMonospace GameFont;
		STATS Stats;

		static CONFIG Config;
};

#endif // _GAME_H

////////////////// End of File : game.h ///////////////////////////////////
